import {validateJobNoOnly} from '@/api/workorder/personcredentialmanage.js'
import { validatenull } from '@/util/validate.js'

var jobID = null;
export function validateFlg(t,id){
  jobID = id;
}

var validateJobNo = (rule, value, callback)=>{
  if (validatenull(value)) {
    callback(new Error('请输入员工号'));
  } else {
    validateJobNoOnly(jobID,value).then(response=>{
      if(response.data.data){
        callback()
      }else{
        callback(new Error('员工号已存在'))
      }
    })
  }
};
export const tableOption ={
  border: true,
  index: true,
  indexLabel: "序号",
  stripe: true,
  menuAlign: "center",
  align: "center",
  searchMenuSpan: 4,
    searchSpan: 4,
  searchMenuPosition: 'left',
  searchEnter: true,
   searchIndex:4,
          searchIcon:true,
  column: [

    {
      type: "input",
      label: "",
      prop: "mergeSearch",
      span: 12,
      display: false,
      hide: true,
      search: true,
      searchPlaceholder: "请输入员工号或人员名称",
      searchLabelWidth:1,
    },
    {
      type: "input",
      label: "员工号",
      prop: "jobNo",
      span: 12,
      rules: [{  required: true,validator: validateJobNo, trigger: 'blur' }]
    },
    {
      type: "input",
      label: "人员名称",
      prop: "personName",
      span: 12,
     /* rules: [
        {
          required: true,
          message: "人员名称不能为空"
        }
      ],*/
    },
    {
      type: "input",
      label: "资质等级",
      prop: "credentialGrade",
      span: 12,
   /*   rules: [
        {
          required: true,
          message: "资质等级不能为空"
        }
      ],*/
    },
    {
      type: "select",
      label: "厂内技能",
      prop: "skill",
      span: 12,
      multiple: true,
      dicUrl: '/admin-api/o3-pfoc/pfocprocess/getPfocProcessList',
      props: {
        label: "processName",
        value: "processName"
      },
      dicMethod: "get",
   /*   rules: [
        {
          required: true,
          message: "请选择厂内技能"
        }
      ],*/
    }
  ]
}
